package com.springboot.fram.core.encryption;

/**
 * @author liheng
 * @ClassName BytesToHexString
 * @Description
 * @date 2020-05-08 4:04
 */
public class BytesToHexString {
    /**
     * 字节转16进制
     *
     * @param src
     * @return
     */
    public static String toString(byte[] src) {
        StringBuffer sb = new StringBuffer(src.length * 2);
        for (int i = 0; i < src.length; i++) {
            int v = src[i] & 0xff;
            if (v < 16) {
                sb.append(0);
            }
            sb.append(Integer.toHexString(v));
        }
        return sb.toString();
    }

}
